package com.yjhb.android.sbz.tool;

import com.yjhb.android.sbz.App;
import com.yjhb.android.sbz.BuildConfig;
import com.yjhb.android.sbz.Conf;
import com.jojo.android.zxlib.tool.ZxSPTool;

/**
 * 创建者 zx
 * 创建时间 2020/12/11 9:17
 */
public class DataSaveTool {

    /**
     * 是否展示快审小提示
     *
     * @return
     */
    public static boolean isRapidlyCheckTips() {
        return (boolean) ZxSPTool.getParam(App.getInstance(), Conf.SP_RAPIDLY_CHECK_TIPS, true);
    }

    /**
     * 记录是否展示快审小提示
     *
     * @param b
     */
    public static void saveRapidlyCheckTips(boolean b) {
        ZxSPTool.setParam(App.getInstance(), Conf.SP_RAPIDLY_CHECK_TIPS, b);
    }

    /**
     * 是否展示隐私协议弹窗
     *
     * @return
     */
    public static boolean isShowPrivacyTips() {
        return (boolean) ZxSPTool.getParam(App.getInstance(), Conf.SP_PRIVACY, true);
    }

    /**
     * 记录是否展示隐私协议弹窗
     */
    public static void saveShowPrivacyTips(Boolean b) {
        ZxSPTool.setParam(App.getInstance(), Conf.SP_PRIVACY, b);
    }

    /**
     * 是否展示任务详情提示信息
     *
     * @return
     */
    public static boolean isShowTaskTips() {
        return (boolean) ZxSPTool.getParam(App.getInstance(), Conf.SP_USER_TASK_TIPS, true);
    }

    /**
     * 记录详情提示是否展示
     *
     * @param b
     */
    public static void saveShowTaskTips(boolean b) {
        ZxSPTool.setParam(App.getInstance(), Conf.SP_USER_TASK_TIPS, b);
    }

    /**
     * 是否展示任务提交时的提示信息
     *
     * @return
     */
    public static boolean isShowTaskSubmitTips() {
        return (boolean) ZxSPTool.getParam(App.getInstance(), Conf.SP_USER_TASK_SUBMIT_TIPS, true);
    }

    /**
     * 保存任务提交时是否展示提示信息
     *
     * @param b
     */
    public static void saveShowTaskSubmitTips(boolean b) {
        ZxSPTool.setParam(App.getInstance(), Conf.SP_USER_TASK_SUBMIT_TIPS, b);
    }


    /**
     * 获取当前缓存的主机地址
     *
     * @return
     */
    public static String getHost() {
        return (String) ZxSPTool.getParam(App.getInstance(), Conf.SP_HOST, BuildConfig.Z_DefaultHost);
    }

    public static Integer getIM_APP_ID() {
        String host = getHost();
        if (BuildConfig.ServerURL_TEST.equals(host)) {
            return BuildConfig.IM_APP_ID_TEST;
        }
        return BuildConfig.IM_APP_ID_RELEASE;
    }

    /**
     * 缓存的主机地址
     *
     * @return
     */
    public static void saveHost(String host) {
        ZxSPTool.setParam(App.getInstance(), Conf.SP_HOST, host);
    }

    public static void saveIM_APP_ID(Integer im_app_id) {
        ZxSPTool.setParam(App.getInstance(), Conf.SP_IM_APP_ID, im_app_id);
    }

    /**
     * 获取新人引导弹窗显示的次数
     * @return
     */
    public static int getShowNewUserCount() {
        return (int) ZxSPTool.getParam(App.getInstance(), Conf.SP_NEW_USER_SHOW, 0);
    }

    public synchronized static void addShowNewUserCount() {
        ZxSPTool.setParam(App.getInstance(), Conf.SP_NEW_USER_SHOW,
                getShowNewUserCount() + 1);
    }

    public static void saveShowBondMoney(boolean b){
        ZxSPTool.setParam(App.getInstance(),Conf.SP_BOND_MONEY_SHOW,b);
    }

    /**
     * 是否展示保证金提示
     * @return
     */
    public static boolean isShowBondMoney(){
        return (boolean) ZxSPTool.getParam(App.getInstance(),Conf.SP_BOND_MONEY_SHOW,true);
    }

}
